/**
 * 
 */
package fr.isima.isipaint.tools;

import javax.swing.ImageIcon;

import fr.isima.isipaint.gui.IsiPaint;
import fr.isima.isipaint.utils.IconsUtils;

/**
 * @author daniel The definition of a tool
 */
public abstract class Action {

	/** The tool name */
	private String name;

	/** The desciption */
	private String description;

	/** The icon to represent this action */
	private ImageIcon icon;

	/** Does the tool have an icon ?? */
	private boolean enableIcon;
	
	/**
	 * @return the enableIcon
	 */
	public final boolean isEnableIcon() {
		return enableIcon;
	}

	/**
	 * @param enableIcon the enableIcon to set
	 */
	public final void setEnableIcon(boolean enableIcon) {
		this.enableIcon = enableIcon;
	}

	/**
	 * @return the name
	 */
	public final String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public final void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public final String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public final void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the icon
	 */
	public final ImageIcon getIcon() {
		return icon;
	}

	/**
	 * Load icons from the defaut icons folder
	 */
	public final void loadIcon() {
		this.icon = IconsUtils.loadIcon(String.format(IsiPaint.IMAGE_LOCATION,
				name.toLowerCase()), description);
	}

	/**
	 * @param name
	 *            the name the action
	 * @param description
	 *            a quick description
	 */
	public Action(String name, String description) {
		setName(name);
		setDescription(description);
	}

	/**
	 * @param name
	 *            the name the action
	 * @param description
	 *            a quick description
	 * @param enableIcon
	 *            enable to add a icon
	 */
	public Action(String name, String description, boolean enableIcon) {
		setName(name);
		setDescription(description);
		setEnableIcon(enableIcon);
		if (isEnableIcon()) {
			loadIcon();
		}
	}

	public abstract void perform();

}
